<?php

/*
 * This file is part of the symfony package.
 * (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

/**
 *
 * @package    symfony
 * @subpackage plugin
 * @author     Fabien Potencier <fabien.potencier@symfony-project.com>
 * @version    SVN: $Id: sfGuardUserPeer.php 7634 2008-02-27 18:01:40Z fabien $
 */
class sfGuardUserPeer extends PluginsfGuardUserPeer
{
    public static function doSelectTeachers(Criteria $criteria, PropelPDO $con = null)
    {
        if ($con === null)
        {
            $con = Propel::getConnection(sfGuardUserPeer::DATABASE_NAME, Propel::CONNECTION_READ);
        }
        if (!$criteria->hasSelectClause())
        {
            $criteria = clone $criteria;
            sfGuardUserPeer::addSelectColumns($criteria);
        }

     //   $criteria->addJoin(sfGuardUserProfilePeer::USER_ID, sfGuardUserPeer::ID);
        $criteria->addJoin(sfGuardUserPeer::ID, sfGuardUserPermissionPeer::USER_ID);
        $criteria->addJoin(sfGuardUserPermissionPeer::PERMISSION_ID, sfGuardPermissionPeer::ID);
        $criteria->add(sfGuardPermissionPeer::NAME, 'teacher');

        return sfGuardUserPeer::doSelect($criteria);
    }

    public static function doCountTeachers(Criteria $criteria, PropelPDO $con = null)
    {
        if ($con === null)
        {
            $con = Propel::getConnection(sfGuardUserPeer::DATABASE_NAME, Propel::CONNECTION_READ);
        }
        if (!$criteria->hasSelectClause())
        {
            $criteria = clone $criteria;
            sfGuardUserPeer::addSelectColumns($criteria);
        }
      //  $criteria->addJoin(sfGuardUserProfilePeer::USER_ID, sfGuardUserPeer::ID);
        $criteria->addJoin(sfGuardUserPeer::ID, sfGuardUserPermissionPeer::USER_ID);
        $criteria->addJoin(sfGuardUserPermissionPeer::PERMISSION_ID, sfGuardPermissionPeer::ID);
        $criteria->add(sfGuardPermissionPeer::NAME, 'teacher');

        return sfGuardUserPeer::doCount($criteria);
    }
}
